/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.Kernel;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.ListProperty;
import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.MetaTypedList;
import edu.pku.sei.modeler.model.uml.Communications.Reception;
import edu.pku.sei.modeler.model.xml.XMLUtility;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;
import edu.pku.sei.modeler.uml.util.MetaTypedSet;


/**
 * @generated
 *
 * modified by zsj
 */
public class UMLClass extends Classifier implements IUMLClass {
	// attributes
	
	protected boolean isActive;
	
	
	
	
	// references
	
	protected MetaTypedList ownedAttribute;
	
	protected MetaTypedList nestedClassifier;
	
	protected MetaTypedList ownedOperation;
	
	protected MetaTypedList superClass;
	
	protected MetaTypedList ownedReception;
	
	
	
	// getters & setters for attributes
	
	@MethodProperty(
			id = "UMLCLASS_ISACTIVE",
			catalog = "General",
			name = ModelPackage.UMLCLASS_ISACTIVE,
			setter = "setIsActive"
			)
	
	public boolean getIsActive() {
		return isActive;
	}
	public void setIsActive(boolean newIsActive) {
		boolean oldisActive = isActive;
		isActive = newIsActive;
		firePropertyChange(ModelPackage.UMLCLASS_ISACTIVE, oldisActive, newIsActive);
	}
	
	// getters for references
	@MethodProperty(
			id = "CLASS_ATTRIBUTES",
			catalog = "Other",
			name = ModelPackage.UMLCLASS_OWNEDATTRIBUTE
			)
	@ListProperty(
			allowTypes = {Property.class},
			newInstanceMethod = "newInstance",
			typeString = ModelPackage.__PROPERTY__
			)
	public MetaTypedList getOwnedAttribute() {
		if(ownedAttribute == null) {
			ownedAttribute = new MetaTypedSet(Property.class, this, ModelPackage.UMLCLASS_OWNEDATTRIBUTE);
		}
		return ownedAttribute;
	}
	
	public MetaTypedList getNestedClassifier() {
		if(nestedClassifier == null) {
			nestedClassifier = new MetaTypedSet(Classifier.class, this, ModelPackage.UMLCLASS_NESTEDCLASSIFIER);
		}
		return nestedClassifier;
	}
	@MethodProperty(
			id = "CLASS_OPERATIONS",
			catalog = "Other",
			name = ModelPackage.UMLCLASS_OWNEDOPERATION
			)
	@ListProperty(
			allowTypes = {Operation.class},
			newInstanceMethod = "newInstance",
			typeString = ModelPackage.__OPERATION__
			)
	public MetaTypedList getOwnedOperation() {
		if(ownedOperation == null) {
			ownedOperation = new MetaTypedSet(Operation.class, this, ModelPackage.UMLCLASS_OWNEDOPERATION);
		}
		return ownedOperation;
	}
	
	public MetaTypedList getSuperClass() {
		if(superClass == null) {
			superClass = new MetaTypedSet(UMLClass.class, this, ModelPackage.UMLCLASS_SUPERCLASS);
		}
		return superClass;
	}
	
	public MetaTypedList getOwnedReception() {
		if(ownedReception == null) {
			ownedReception = new MetaTypedSet(Reception.class, this, ModelPackage.UMLCLASS_OWNEDRECEPTION);
		}
		return ownedReception;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.UMLCLASS_ISACTIVE, isActive);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.UMLCLASS_OWNEDATTRIBUTE, ownedAttribute);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.UMLCLASS_NESTEDCLASSIFIER, nestedClassifier);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.UMLCLASS_OWNEDOPERATION, ownedOperation);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.UMLCLASS_SUPERCLASS, superClass);		
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.UMLCLASS_OWNEDRECEPTION, ownedReception);
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		isActive = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.UMLCLASS_ISACTIVE);
		
		// references
		
		this.getOwnedAttribute().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.UMLCLASS_OWNEDATTRIBUTE));
		
		this.getNestedClassifier().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.UMLCLASS_NESTEDCLASSIFIER));
		
		this.getOwnedOperation().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.UMLCLASS_OWNEDOPERATION));
		
		this.getSuperClass().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.UMLCLASS_SUPERCLASS, this));
		
		this.getOwnedReception().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.UMLCLASS_OWNEDRECEPTION));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		// references
		
		else if(ModelPackage.UMLCLASS_SUPERCLASS.equals(featureID)) {
			getSuperClass().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 